package com.robbykrlos.androbert;

import android.util.Pair;

import java.sql.Time;
import java.util.Random;

/**
 * Created by RobbyKrlos on 06.12.2014.
 */
public class GameObstacle {

    public class ObstacleTypes {
        public static final byte NONE = (byte)0x00;
        public static final byte POINT = (byte)0x02;
        public static final byte PENALTY = (byte)0x01;
        public static final byte WALL_N = (byte)0x10;
        public static final byte WALL_E = (byte)0x08;
        public static final byte WALL_S = (byte)0x20;
        public static final byte WALL_W = (byte)0x04;
    }

    public class ObstacleCodes {
        //SPECIAL
        public static final char NONE = '.';
        public static final char POINT = 'o';
        public static final char PENALTY = '*';
        public static final char START = 'u';

        //ALL
        public static final char WALL_X = 'O';

        //SIMPLE
        public static final char WALL_N = 'C';
        public static final char WALL_E = 'B';
        public static final char WALL_S = 'D';
        public static final char WALL_W = 'A';

        //DOUBLE
        //North
        public static final char WALL_NE = 'I';
        public static final char WALL_NS = 'F';
        public static final char WALL_NW = 'G';
        //East
        public static final char WALL_ES = 'J';
        public static final char WALL_EW = 'E';
        //South
        public static final char WALL_SW = 'H';

        //TRIPLE
        public static final char WALL_NES = 'N';
        public static final char WALL_ESW = 'L';
        public static final char WALL_SWN = 'M';
        public static final char WALL_WNE = 'K';
    }


    private Pair <Integer, Integer> pairObstaclePos = new Pair<Integer, Integer>(0,0);
    private byte obstacleType = ObstacleTypes.NONE;

    public GameObstacle (){
        this.pairObstaclePos = new Pair<Integer, Integer>(0,0);
    }
    public GameObstacle (Pair <Integer, Integer> pairObstaclePos){
        this.pairObstaclePos = pairObstaclePos;
    }

    public void setPairObstaclePos(Pair<Integer, Integer> pairObstaclePos) {
        this.pairObstaclePos = pairObstaclePos;
    }
    public Pair<Integer, Integer> getPairObstaclePos() {
        return pairObstaclePos;
    }

    public void setObstacleType(byte obstacleType) {
        this.obstacleType = obstacleType;
    }
    public byte getObstacleType() {
        return this.obstacleType;
    }

    /**
     * Generate Random Obstacle at Random X,Y pair coordinates.
     * TODO : doesn't double-check for duplicated obstacles.
     * @param intMaxGamePlanDimension
     * @return GameObstacle
     */
    public static GameObstacle generateObstacle(Integer intMaxGamePlanDimension){
        Integer intXpos = new Random().nextInt() % intMaxGamePlanDimension;
        Integer intYpos = new Random().nextInt() % intMaxGamePlanDimension;
        return new GameObstacle(new Pair<Integer, Integer>(intXpos, intYpos));
    }
}
